﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class lotteryInfo : System.Web.UI.Page
{
    protected long id = ReadRequest.RequestLong("id");
    protected Model.LotteryBuyDetail buyInfo = null;
    public string str = "";
    protected string SSQQQD = null;
    protected string SSQQQT = null;
    protected string SSQHQD = null;
    protected string SSQHQT = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        buyInfo = BLL.LotteryBuyDetail.GetModel(id);
        Bind();

    }
    private long SSQFS(int n)
    {
        long sum = 1;
        if (n == 0 || n == 1)
        {
            return 1;
        }
        else
        {
            for (int i = 1; i <= n; i++)
            {
                sum *= i;
            }
            return sum;
        }
    }
    private void Bind()
    {
        if (buyInfo != null)
        {
            string lotteryNo = buyInfo.LotteryNo;
            if (buyInfo.LotteryType == 1)
            {
                # region 双色球 前端显示
                string[] strList = lotteryNo.Split(','); 
                for (int i = 0; i < strList.Length; i++)
                {
                    string[] ssqflaglist = strList[i].Split('+');
                    string[] redBall = ssqflaglist[0].Split('$');  
                    //胆拖
                    if (redBall.Length > 1)
                    {
                        string[] dstr = redBall[0].Split('*');
                        string listStr1 = "";
                        for (int j = 0; j < dstr.Length; j++)
                        {
                            listStr1 += dstr[j] + ",";
                        }
                        string[] tstr = redBall[1].Split('*');
                        string listStr2 = "";
                        for (int j = 0; j < tstr.Length; j++)
                        {
                            listStr2 += tstr[j] + ",";
                        }
                        string[] blutstr = ssqflaglist[1].Split('*');
                        string blutstrr = "";
                        for (int j = 0; j < blutstr.Length; j++)
                        {
                            blutstrr += blutstr[j] + ",";
                        }
                        str += " <tr><td><span  style=\"color:Red\"> 红球</span>：胆码（" + listStr1.TrimEnd(',') + "）;拖码（"
                            + listStr2.TrimEnd(',') + "）<br/> <span  style=\"color:Blue\"> 蓝球</span>：（"
                            + blutstrr.TrimEnd(',') + "）;</td><td>胆拖[" 
                            + (SSQFS(tstr.Length) / SSQFS(6 - dstr.Length) / SSQFS(tstr.Length - 6 + dstr.Length)) * ssqflaglist[1].Split('*').Length + "注]</td></tr>";
              
                    }
                    if (redBall.Length == 1)
                    { 
                        string play = "";
                        if (ssqflaglist[0].Split('*').Length > 6 && ssqflaglist[1].Split('*').Length > 1)
                        {
                            play = "全复式";
                        }
                        else if (ssqflaglist[0].Split('*').Length > 6 || ssqflaglist[1].Split('*').Length > 1)
                        {
                            play = "复式";
                        }else
                        {
                            play = "单式";
                        }
                        string[] dstr = ssqflaglist[0].Split('*');
                        string listStr1 = "";
                        for (int j = 0; j < dstr.Length; j++)
                        {
                            listStr1 += dstr[j] + ",";
                        }
                        string[] tstr = ssqflaglist[1].Split('*');
                        string listStr2 = "";
                        for (int j = 0; j < tstr.Length; j++)
                        {
                            listStr2 += tstr[j] + ",";
                        }
                        str += " <tr><td><span  style=\"color:Red\"> 红球</span>：（"
                            + listStr1.TrimEnd(',') + "）;<br/> <span  style=\"color:Blue\"> 蓝球</span>：（"
                            + listStr2.TrimEnd(',') + "）</td><td>" + play + "["
                            + (SSQFS(ssqflaglist[0].Split('*').Length) / SSQFS(6) / SSQFS(ssqflaglist[0].Split('*').Length - 6))*ssqflaglist[1].Split('*').Length + "注]</td></tr>";
          

                    }
                } 
                 
                # endregion
            }
            else if (buyInfo.LotteryType == 2)
            {
                # region 大乐透 前端显示 
                string[] strList = lotteryNo.Split(',');
                for (int i = 0; i < strList.Length; i++)
                {
                    string[] ssqflaglist = strList[i].Split('+');
                    string[] redBall = ssqflaglist[0].Split('$');
                    string[] blueBall = ssqflaglist[1].Split('$');
                    //胆拖
                    if (redBall.Length > 1)
                    {
                        string[] dstr = redBall[0].Split('*');
                        string listStr1 = "";
                        for (int j = 0; j < dstr.Length; j++)
                        {
                            listStr1 += dstr[j] + ",";
                        }
                        string[] tstr = redBall[1].Split('*');
                        string listStr2 = "";
                        for (int j = 0; j < tstr.Length; j++)
                        {
                            listStr2 += tstr[j] + ",";
                        }
                        string[] blutstr = blueBall[0].Split('*');
                        string blutstrr = "";
                        for (int j = 0; j < blutstr.Length; j++)
                        {
                            blutstrr += blutstr[j] + ",";
                        }
                        if (blueBall.Length > 1)
                        {
                            string[] bltstr = blueBall[1].Split('*');
                            string bltstrt = "";
                            for (int j = 0; j < bltstr.Length; j++)
                            {
                                bltstrt += bltstr[j] + ",";
                            }
                            str += " <tr><td><span  style=\"color:Red\"> 前区</span>：胆码（" + listStr1.TrimEnd(',') + "）;拖码（"
                                + listStr2.TrimEnd(',') + "）<br/> <span  style=\"color:Blue\"> 后区</span>：（"
                                + blutstrr.TrimEnd(',') + "）;</td><td>胆拖["
                                + (SSQFS(tstr.Length) / SSQFS(5 - dstr.Length) / SSQFS(tstr.Length - 5 + dstr.Length)) * (SSQFS(bltstr.Length) / SSQFS(2 - blutstr.Length) / SSQFS(bltstr.Length - 5 + blutstr.Length)) + "注]</td></tr>";

                        }
                        else
                        { 
                            str += " <tr><td><span  style=\"color:Red\"> 前区</span>：胆码（"
                                + listStr1.TrimEnd(',') + "）;拖码（" + listStr2.TrimEnd(',') + "）<br/> <span  style=\"color:Blue\"> 后区</span>：("
                                + blutstrr.TrimEnd(',') + "）;</td><td>胆拖["
                                + (SSQFS(tstr.Length) / SSQFS(5 - dstr.Length) / SSQFS(tstr.Length - 5 + dstr.Length)) * (SSQFS(blutstr.Length) / SSQFS(2) / SSQFS(blutstr.Length - 2)) + "注]</td></tr>";

                        }
                    }
                    if (redBall.Length == 1)
                    {
                        string play = "";
                        if (ssqflaglist[0].Split('*').Length > 5 && ssqflaglist[1].Split('*').Length > 2)
                        {
                            play = "全复式";
                        }
                        else if (ssqflaglist[0].Split('*').Length > 5 || ssqflaglist[1].Split('*').Length > 2)
                        {
                            play = "复式";
                        }
                        else
                        {
                            play = "单式";
                        }
                        string[] dstr = ssqflaglist[0].Split('*');
                        string listStr1 = "";
                        for (int j = 0; j < dstr.Length; j++)
                        {
                            listStr1 += dstr[j] + ",";
                        }
                        string[] tstr = ssqflaglist[1].Split('*');
                        string listStr2 = "";
                        for (int j = 0; j < tstr.Length; j++)
                        {
                            listStr2 += tstr[j] + ",";
                        }
                        str += " <tr><td><span  style=\"color:Red\"> 前区</span>：（"
                            + listStr1.TrimEnd(',') + "）;<br/> <span  style=\"color:Blue\"> 后区</span>：（"
                            + listStr2.TrimEnd(',') + "）</td><td>" + play + "["
                            + (SSQFS(ssqflaglist[0].Split('*').Length) / SSQFS(5) / SSQFS(ssqflaglist[0].Split('*').Length - 5)) * (SSQFS(ssqflaglist[1].Split('*').Length) / SSQFS(2) / SSQFS(ssqflaglist[1].Split('*').Length - 2)) + "注]</td></tr>";


                    }
                }

                # endregion 
            }
            else if (buyInfo.LotteryType == 3)
            {
                # region 排列三 前端显示
                string[] strList = lotteryNo.Split(',');
                for (int i = 0; i < strList.Length; i++) {
                    string[] strlist = strList[i].Split('*');
                    string play = "";
                    if (strlist[0].Length > 1 && strlist[1].Length > 1 && strlist[2].Length > 1)
                    {
                        play = "全复式";
                    }
                    else if (strlist[0].Length > 1 || strlist[1].Length > 1 || strlist[2].Length > 1)
                    {
                        play = "复式";
                    }
                    else
                    {
                        play = "单式";
                    }
                    str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + strlist[0] + "," + strlist[1] + "," + strlist[2] + "）</td><td>"
                        + play + "["
                        + strlist[0].Length * strlist[1].Length * strlist[2].Length + "注]</td></tr>";
                } 
                # endregion
            }
            else if (buyInfo.LotteryType == 4)
            {
                # region  排列五 前端显示
                string[] strList = lotteryNo.Split(',');
                for (int i = 0; i < strList.Length; i++)
                {
                    string[] strlist = strList[i].Split('*');
                    string play = "";
                    if (strlist[0].Length > 1 && strlist[1].Length > 1 && strlist[2].Length > 1 && strlist[3].Length > 1 && strlist[4].Length > 1)
                    {
                        play = "全复式";
                    }
                    else if (strlist[0].Length > 1 || strlist[1].Length > 1 || strlist[2].Length > 1 || strlist[3].Length > 1 || strlist[4].Length > 1)
                    {
                        play = "复式";
                    }
                    else
                    {
                        play = "单式";
                    }
                    str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + strlist[0] + "," + strlist[1] + "," + strlist[2] + "," + strlist[3] + "," + strlist[4] + "）</td><td>"
                        + play + "["
                        + strlist[0].Length * strlist[1].Length * strlist[2].Length * strlist[3].Length * strlist[4].Length + "注]</td></tr>";
                }  
                # endregion
            }
            else if (buyInfo.LotteryType == 6)
            {
                # region   七星彩 前端显示
                string[] strList = lotteryNo.Split(',');
                for (int i = 0; i < strList.Length; i++)
                {
                    string[] strlist = strList[i].Split('*');
                    string play = "";
                    if (strlist[0].Length > 1 && strlist[1].Length > 1 && strlist[2].Length > 1 && strlist[3].Length > 1 && strlist[4].Length > 1 && strlist[5].Length > 1 && strlist[6].Length > 1)
                    {
                        play = "全复式";
                    }
                    else if (strlist[0].Length > 1 || strlist[1].Length > 1 || strlist[2].Length > 1 || strlist[3].Length > 1 || strlist[4].Length > 1 || strlist[5].Length > 1 || strlist[6].Length > 1)
                    {
                        play = "复式";
                    }
                    else
                    {
                        play = "单式";
                    }
                    str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + strlist[0] + "," + strlist[1] + "," + strlist[2] + "," + strlist[3] + "," + strlist[4] + "," + strlist[5] + "," + strlist[6] + "）</td><td>"
                        + play + "["
                        + strlist[0].Length * strlist[1].Length * strlist[2].Length * strlist[3].Length * strlist[4].Length * strlist[5].Length * strlist[6].Length + "注]</td></tr>";
                }   
                # endregion
            }
            else if (buyInfo.LotteryType == 7)
            {
                # region  七乐彩 前端显示 
                string[] strList = lotteryNo.Split(',');
                for (int i = 0; i < strList.Length; i++)
                {
                    string[] redBall = strList[i].Split('$');
                    //胆拖
                    if (redBall.Length > 1)
                    {
                        string[] dstr = redBall[0].Split('*');
                        string listStr1="";
                        for (int j = 0; j < dstr.Length; j++)
                        { 
                            listStr1 += dstr[j] + "," ;
                        }
                        string[] tstr = redBall[1].Split('*');
                        string listStr2 = "";
                        for (int j = 0; j < tstr.Length; j++)
                        {
                            listStr2 += tstr[j] + ",";
                        }
                        str += " <tr><td><span  style=\"color:Red\"> 选号</span>：胆码（" + listStr1.TrimEnd(',') + "）;拖码（" + listStr2.TrimEnd(',') + "）</td><td>胆拖["
                            + SSQFS(tstr.Length) / SSQFS(7 - dstr.Length) / SSQFS(tstr.Length - 7 + dstr.Length) + "注]</td></tr>";
                    }
                    if (redBall.Length == 1)
                    {
                        string[] strlist = strList[i].Split('*');
                        string play = "";
                        if (strlist.Length>7)
                        {
                            play = "复式";
                        }
                        else
                        {
                            play = "单式";
                        }
                        str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + strlist[0] + "," + strlist[1] + "," + strlist[2] + "," + strlist[3] + "," + strlist[4] + "," + strlist[5] + "," + strlist[6] + "）</td><td>"
                            + play + "["
                            + SSQFS(strlist.Length) / SSQFS(7) / SSQFS(strlist.Length - 7) + "注]</td></tr>";

                    }  
                }   
                # endregion
            }
            else if (buyInfo.LotteryType == 5)
            {
                # region  福彩3D 前端显示 
                if (buyInfo.fcType == 0 || buyInfo.fcType == 1 || buyInfo.fcType == 2 || buyInfo.fcType == 6)//直选 通选 包选
                {
                    string[] strList = lotteryNo.Split(',');
                    for (int i = 0; i < strList.Length; i++)
                    {
                        string[] strlist = strList[i].Split('*');
                        string play = "";
                        if (strlist[0].Length > 1 && strlist[1].Length > 1 && strlist[2].Length > 1)
                        {
                            play = "全复式";
                        }
                        else if (strlist[0].Length > 1 || strlist[1].Length > 1 || strlist[2].Length > 1)
                        {
                            play = "复式";
                        }
                        else
                        {
                            play = "单式";
                        }
                        str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + strlist[0] + "," + strlist[1] + "," + strlist[2] + "）</td><td>"
                            + play + "["
                            + strlist[0].Length * strlist[1].Length * strlist[2].Length + "注]</td></tr>";
                    } 
                }
                if (buyInfo.fcType == 3)//组三
                {
                    string[] winSSQList = lotteryNo.Split(',');
                    for (int i = 0; i < winSSQList.Length; i++)
                    {
                        string[] strlist = winSSQList[i].Split('*');
                        string listStr1 = strlist[0] + "," + strlist[1] + "," + strlist[2];
                        str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + listStr1 + "）;</td><td>组三单式[1注]</td></tr>";
                    }
                }
                if (buyInfo.fcType == 4)//组六
                {
                    string[] winSSQList = lotteryNo.Split(',');
                    for (int i = 0; i < winSSQList.Length; i++)
                    {
                        string[] strlist = winSSQList[i].Split('*');
                        string listStr1 = strlist[0] + "," + strlist[1] + "," + strlist[2];
                        str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + listStr1 + "）;</td><td>组六单式[1注]</td></tr>";
                    }
                }
                if (buyInfo.fcType == 5)//和数
                {
                    string[] winSSQList = lotteryNo.Split(',');
                    if (winSSQList.Length >= 3)
                    {
                        for (int i = 0; i < winSSQList.Length; i++)
                        {
                            string listStr = winSSQList[i];
                            str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + listStr + "）;</td><td>和数[1注]</td></tr>";
                        }
                    }
                } 
                if (buyInfo.fcType == 7)//1D
                {
                        string[] strList = lotteryNo.Split(',');
                        for (int i = 0; i < strList.Length; i++)
                        {
                            string[] strlist = strList[i].Split('*');
                            string play = "";
                            if (strlist[0].Length > 1 || strlist[1].Length > 1 || strlist[2].Length > 1)
                            {
                                play = "复式";
                            }
                            else
                            {
                                play = "单式";
                            }
                            str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + strlist[0] + "," + strlist[1] + "," + strlist[2] + "）</td><td>"
                                + play + "["
                                + (strlist[0].Length + strlist[1].Length + strlist[2].Length-2) + "注]</td></tr>";
                        }
                }
                if (buyInfo.fcType ==8)//2D
                {
                    string[] strList = lotteryNo.Split(',');
                    for (int i = 0; i < strList.Length; i++)
                    {
                        string[] strlist = strList[i].Split('*');
                        string play = "";
                        if ((strlist[0].Length > 1 && strlist[1].Length > 1) || (strlist[2].Length > 1 && strlist[1].Length > 1) || (strlist[0].Length > 1 && strlist[2].Length > 1))
                        {
                            play = "全复式";
                        }
                        else if (strlist[0].Length > 1 || strlist[1].Length > 1 || strlist[2].Length > 1)
                        {
                            play = "复式";
                        }
                        else
                        {
                            play = "单式";
                        }
                        str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + strlist[0] + "," + strlist[1] + "," + strlist[2] + "）</td><td>"
                            + play + "["
                            + (strlist[0].Length * strlist[1].Length + strlist[0].Length * strlist[2].Length + strlist[2].Length * strlist[1].Length - strlist[0].Length - strlist[1].Length - strlist[2].Length + 1) + "注]</td></tr>";
                    }
                }
                if (buyInfo.fcType == 9)//大小奇偶
                {
                    string[] winSSQList = lotteryNo.Split(',');
                        for (int i = 0; i < winSSQList.Length; i++)
                        {
                            string listStr = winSSQList[i];
                            string ss = listStr.Equals("1") ? "小" : (listStr.Equals("2") ? "大" : (listStr.Equals("3") ? "奇" : (listStr.Equals("4") ? "偶" : "无")));
                            str += " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + ss + "）;</td><td>和数[1注]</td></tr>";
                        }
                }
                if (buyInfo.fcType == 10)//拖拉机
                {
                    str = " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + lotteryNo + "）;</td><td>拖拉机[" + buyInfo.LotteryCount + "注]</td></tr>";
                }
                if (buyInfo.fcType == 11)//猜三同
                {
                    str = " <tr><td><span  style=\"color:Red\"> 选号</span>：（" + lotteryNo + "）;</td><td>猜三同[" + buyInfo.LotteryCount + "注]</td></tr>";
                }
                # endregion
            }
        }
    }
}